<?php

namespace App\Http\Controllers\Video;

use App\Models\Video;
use App\Jobs\UploadVideo;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class VideoUploadController extends Controller
{
    public function index()
    {
        return view('videos.upload');
    }


    public function store(Request $request)
    {
        $video = Video::where('user_id', auth()->id())->where('id', $request->id)->firstOrFail();
        //save to loadtion
        $request->file('video')->move(storage_path() . '/uploads', $video->video_filename);
        //执行队列
        if ($this->dispatch(new UploadVideo($video->video_filename))) {
            return response()->json(['status' => 'success' , 'msg' => '视频上传成功!']);
        }
    }
}
